<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>意见反馈</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="../demo.css" rel="stylesheet" type="text/css" />
    <script src="../../scripts/boot.js" type="text/javascript"></script>
    <style type="text/css">
    html,body
    {
        width:100%;
        height:100%;
        border:0;
        margin:0;
        padding:0;
        overflow:visible;
    }
    </style>
</head>
<body >   
	   <div class="mini-toolbar" style="border:0;">
        <table style="width:100%;">
            <tr>
            <td style="width:100%;">
                  <a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a>
                  <span class="separator"></span>
                  <a class="mini-button" iconCls="icon-reload" plain="true" onclick="search();">刷新</a>
             </td>
             <td style="white-space:nowrap;">
                 <label style="font-family:Verdana;">用户ID: </label>
                 <input id="key" class="mini-textbox"/>
                 <a class="mini-button" iconCls="icon-search" plain="true" onclick="search();">查询</a>
             </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
            url="/ios/pages/Suggestion/list.do"  idField="id" sizeList="[5,10,20,50]" pageSize="20"
               multiSelect="true" allowCellValid="true" oncellvalidation="onCellValidation" >
            <div property="columns">
                <div type="indexcolumn" width="20"></div>
                <div type="checkcolumn"></div>
                <div field="username"   headerAlign="center" allowSort="true" >用户ID</div>
                <div field="crdate"  headerAlign="center"  allowSort="true">时间</div>
                <div field="content" headerAlign="center"  allowSort="true" >内容</div>
               <!--   <div field="hudate"  headerAlign="center"  allowSort="true">回复时间</div>
                <div field="content2" headerAlign="center"   allowSort="true">回复内容</div>
                <div field="id"  headerAlign="center"  renderer="onHandleRenderer" width="70" >操作</div>-->
            </div>
        </div> 
    </div>
    <!--添加和编辑页面-->
   <div id="editWindow" class="mini-window" title="回复" style="width:480px;height:245px;display: none;" showModal="true" allowResize="true" iconCls="icon-save" allowDrag="true" >
	    <div id="editform"  class="form">
	      <input class="mini-hidden" name="id" id="mytest"/>
	      <fieldset style="width:420px;height:140px;border:solid 1px #aaa;margin-top:8px;position:relative;">
          <legend>信息</legend>
	         <textarea class="mini-textarea" name="remark" style="width:100%;height: 80%" emptyText="请输入备注"></textarea>
	      </fieldset>
	       <div align="right" style="padding: 10px">
                  <a class="mini-button" iconCls="icon-save" href="javascript:saveRow()">保存</a> 
                  <a class="mini-button" iconCls="icon-close" href="javascript:cancelRow()">关闭</a>
	       </div>       
	    </div>
	</div>
    <script type="text/javascript">
         function onHandleRenderer(e) {
            var grid = e.sender;
            var record = e.record;
            var id = record.id;
            var s ='';
            if(record.hudate==''){
	            s =s+'&nbsp;&nbsp;<a class="New_Button" href="javascript:editRow(\''+id+'\');">回复</a>';
            }
            return s;
        }	
       
        mini.parse();
        var form = new mini.Form("#editform");
        var editWindow = mini.get("#editWindow");
        var grid = mini.get("datagrid1");
        grid.load();
        
        function search() {  
            var key = mini.get("key").getValue();
            grid.load({username:key}); 
            grid.clearSelect();    
        }
        
        function newRow() { 
            form.clear();  
            editWindow.show();
            editWindow.setTitle("添加"); 
        }
        
        function reset() { 
            form.clear();        
        }
        
         
        function editRow(id) {
            form.clear();
            editWindow.show();
        	mini.get("mytest").setValue(id);
        }
        
        function cancelRow() {
            editWindow.hide();
        }
        
        function saveRow() {
            form.validate();
            if (form.isValid() == false) return;
            var data = form.getData();
            var json = mini.encode(data);
            form.loading();
            $.ajax({
                url: "/ios/pages/Suggestion/save.do",
                type: "post",
                data: {submitData:json },
                success: function (text) {
                    var o = mini.decode(text);
                     if(o.state){
                         form.unmask();
                         grid.load();
                         editWindow.hide();
                     }else{
                         form.unmask();
                         alert("保存出错了!");
                     }
                },
                error: function (jqXHR, textStatus, errorThrown) {
			         alert("请求出错了!");
			    }
            });
        }
        
         function removeRow() {
         	var rows = grid.getSelecteds();
         	var ids="";
         	for(i=0;i<rows.length;i++){
         	    ids+="'"+rows[i].id+"',";
         	}
         	mini.confirm("确定删除记录？", "确定？",
	            function (action, value) {            
	                if (action == "ok") {
		                 if (rows.length>0) {
	                    	var messageid = mini.loading("正在执行...", "wait");
			                $.ajax({
			                    url: "/originrice/pages/Dealer/delete.do?id="+ids,
			                    success: function (text) {
			                       var o = mini.decode(text);
			                       mini.hideMessageBox(messageid);
                     			   if(o.state){
				                         grid.load();
                     			   }else{
                     			     mini.alert("删除出错");
                     			   }
			                    },
			                    error: function () {
			                   		mini.hideMessageBox(messageid);
			                   		mini.alert("删除出错");
			                    }
			                });
		                } else {
		                    return;
		            	}
	               }else{
	                  return;
	               }
            },true);
        }
    </script>
</body>
</html>

